﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Vit.DataAccess;
using Vit.SchemaExplorer;

namespace Vit.Data
{
    public class DataContext : IDisposable
    {
        protected Database database;
        protected DatabaseSchema databaseSchema;

        public DataContext(string connectionStringName)
        {
            database = DatabaseFactory.Create(connectionStringName);
            databaseSchema = DatabaseSchemaFactory.Create(connectionStringName);
        }

        #region IDisposable Members

        public virtual void Dispose()
        {
            if (database != null)
            {
                database = null;
            }
            if (databaseSchema != null)
            {
                databaseSchema = null;
            }
        }

        #endregion

        public Database Database
        {
            get
            {
                return database;
            }
        }

        public DatabaseSchema DatabaseSchema
        {
            get
            {
                return databaseSchema;
            }
        }
    }
}
